<?php
namespace app\model\product;

use think\Model;

class ZxlKnowStoreCategoryModel extends Model
{
    protected $name = 'zxl_know_store_category';

    /**
     * 根据类型获取一级分类
     * 
     * @param int $type 类型
     * @return array
     */
    public static function first_category($m_id, $type)
    {
        $list = ZxlKnowStoreCategoryModel::where(['m_id' => $m_id, 'type' => $type, 'status' => 1, 'is_delete' => 0])->select()->toArray();
        return $list;
    }

    /**
     * 根据一级分类获取二级分类
     * 
     * @param int $p_id 父级ID
     * @return array
     */
    public static function second_category($m_id, $p_id)
    {
        $list = ZxlKnowStoreCategoryModel::where(['m_id' => $m_id, 'parent_id' => $p_id, 'status' => 1, 'is_delete' => 0])->select()->toArray();

        return $list;
    }
}